


class UserController {
  static async listUsers(ctx, next) {
    next()

    console.log(ctx.query);
    let start = +ctx.query.currentPage
    let limit = +ctx.query.pageSize

    let a = (start - 1) * limit
    console.log(a);
    console.log(limit);

    const [rows, fields] = await ctx.promisePool.query('select * from user_session limit ?, ?', [a, limit]);
    const [rows2, fields2] = await ctx.promisePool.query('select count(*) as total from user_session')

    console.log(rows2[0].total);


    ctx.set("Content-Type", "application/json")


    ctx.body = JSON.stringify({
      page: { total: rows2[0].total },
      result: rows
    })

  }

  static async showUserDetail(ctx) {
    ctx.body = `ShowUserDetail controller with ID = ${ctx.params.id}`;
  }

  static async updateUser(ctx) {
    ctx.body = `UpdateUser controller with ID = ${ctx.params.id}`;
  }

  static async deleteUser(ctx) {
    ctx.body = `DeleteUser controller with ID = ${ctx.params.id}`;
  }
}

module.exports = UserController